package com.mgr.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import com.mgr.service.SendEmail;

public class SendEmailImpl implements SendEmail {
	@Autowired
	private JavaMailSender mailSender;

	@Override
	public boolean  sendEmail(String custName, String verifyLink,String password, String emailAdd) {
		boolean isSend=true;
		String content = "Hi " + custName + "\n";
		content += "You recently joined one of the ABC-bank services.\n";
		content+="Your password is: "+password+"\n";
		content += "To confirm your email address, click on the link below:\n";
		content += verifyLink;
		try {
			SimpleMailMessage eMessage = new SimpleMailMessage();
			eMessage.setTo(emailAdd);
			eMessage.setSubject("Verify your mail address with ABC-bank service");
			eMessage.setText(content);

			mailSender.send(eMessage);
		} catch (Exception e) {
			isSend=false;
			System.out.println("Error send email!");
		}
		return isSend;
	}

}